package com.aboat.view;

import com.aboat.licenseVerify.Permitted;
import com.aboat.model.ImageCrawler;
import com.aboat.view.panel.*;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.util.ArrayList;


/**
 * 程序界面
 *
 * @author aboat
 * @email clear_windy@yeah.net
 * @create 2017-04-03 13:02
 */
public class WindowFrame extends JFrame{
    public static DefaultTableModel seedTableModel;//种子列表实体
    public static ArrayList<String> seedList = new ArrayList<>();//种子列表
    public static DefaultTableModel splusRegularTableModel;//允许正则列表实体
    public static DefaultTableModel minusRegularTableModel;//禁止正则列表实体
    public static ArrayList<String> regularList = new ArrayList<>();//正则列表,允许的开头加+，禁止的开头加-

    public static JSlider threadSlider = new JSlider(1,16,4);//线程数
    public static JSlider depthSlider = new JSlider(1,16,4);//爬去深度
    public static JTextField textStoragePath = new JTextField("D:/spider",29);//存储路径
    public static JTextField tagField = new JTextField("img[src]",36);//提取标签

    public static JTextArea textContent = new JTextArea (8,130);//面板记录输出

    public static Long maxNum = 200l;//下载最大数限制
    public static ImageCrawler crawler;
    public static JButton actionButton;//启动按钮

    public WindowFrame(){
        setTitle("蜘蛛");
        setSize(1000, 650);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setResizable(false);
        setLocationRelativeTo(null);
        /*ImageIcon image = new ImageIcon("/boat.png");
        setIconImage(image.getImage());*/
        setJMenuBar(new ControlMenu());

        GridBagLayout gridbag = new GridBagLayout();
        setLayout(gridbag);

        add(new SeedPanel(),new GBC(0,0,1,1).setWeight(300,100).setInsets(1));
        add(new PlusRegularPanel(),new GBC(1,0,1,1).setWeight(300,100).setInsets(1));
        add(new MinusRegularPanel(),new GBC(2,0,1,1).setWeight(300,100).setInsets(1));
        add(new OtherPanel(),new GBC(0,1,3,1).setWeight(900,50).setInsets(1));
        add(new InfoPanel(),new GBC(0,2,3,1).setWeight(900,250).setInsets(1));

        Permitted.verifyLicense(null);

        setVisible(true);
    }
}
